﻿package config;

import org.json.simple.JSONObject;

import util.KJsonObject;

public class SystemDefine {
	// login
	private int					LOGIN_ID;
	
	private int					Register_ID;
	
	private int					chatId;
	
	private int					PokerID;
	
	private int					ROLE_ID;
	
	private int					MapID;
	
	static private SystemDefine	systemDefine;
	
	private JSONObject			jsonObject;
	
	public SystemDefine() {
		
	}
	
	static public SystemDefine getInstance() {
		if (systemDefine == null) {
			systemDefine = new SystemDefine();
		}
		return systemDefine;
	}
	
	// 加载配置文件
	public Boolean loadConfing() {
		LoadFile loadFile = new LoadFile();
		
		String fileString = loadFile.Load("config/systemDefine");
		jsonObject = KJsonObject.decode(fileString);
		
		return initConfigData();
	}
	
	private Boolean initConfigData() {
		LOGIN_ID = intChange(jsonObject.get("LOGIN_ID"));
		
		chatId = intChange(jsonObject.get("CHAT_ID"));
		
		
		Register_ID = intChange(jsonObject.get("Register_ID"));
		
		PokerID = intChange(jsonObject.get("PokerID"));
		
		ROLE_ID = intChange(jsonObject.get("ROLE_ID"));
		
		MapID = intChange(jsonObject.get("MapID"));
		return true;
	}
	
	/**
	 * 转成int 类型
	 * 
	 * @param obj
	 * @return
	 */
	private int intChange(Object obj) {
		return Integer.parseInt(String.valueOf(obj));
	}
	
	public JSONObject getJsonObject() {
		return jsonObject;
	}
	
	public int getLOGIN_ID() {
		return LOGIN_ID;
	}
	
	public int getChatId() {
		
		return chatId;
	}
	
	 
	public int getPokerID() {
		return PokerID;
	}
	
	public int getRegister_ID() {
		return Register_ID;
	}
	
	public int getROLE_ID() {
		return ROLE_ID;
	}
	
	public int getMapID() {
		return MapID;
	}
	
	// /end class
}
